package com.lp.module_home_c.dialog;

import android.app.Activity;
import android.view.Gravity;
import android.view.View;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.lp.module_home_c.R;
import com.lp.module_home_c.adapter.HomeCTextAdapter;
import com.lp.module_home_c.bean.TextBean;
import com.lp.module_lib.base.BaseDialog;
import com.lp.module_lib.utils.UiUtils;

import java.util.List;

/**
 * 作者：created by LP_TREAM on 2020/11/28 23:51
 * 邮箱：806875201@qq.com
 */
public class TextDialogUtils {
    private static BaseDialog dialog;
    private static Activity mContext;

    public interface OnClickListener {
        void onClickView(View v);
    }

    public static BaseDialog.Builder showDialog(Activity context, List<TextBean.DataBean> mBeans, OnClickListener listener) {
        mContext = context;

        BaseDialog.Builder builder = new BaseDialog.Builder(context);
        dialog = builder.setView(R.layout.home_c_dialog_text)
                .setWindowAnimations(R.style.DialogBottomAnim)
                .setCancelTouchout(true)
                .setGravity(Gravity.BOTTOM)
                .setHeightdp(UiUtils.getScreenHeight() / 2 - 200)
                .build();
        initView(builder, mBeans, listener);
        dialog.show();
        return builder;
    }

    private static void initView(BaseDialog.Builder builder, List<TextBean.DataBean> mBeans, OnClickListener listener) {
        RecyclerView mRecyclerView = builder.findViewById(R.id.recyclerView);

        LinearLayoutManager mLayoutManager = new LinearLayoutManager(mContext);
        mLayoutManager.setOrientation(RecyclerView.VERTICAL);
        mRecyclerView.setLayoutManager(mLayoutManager);

        HomeCTextAdapter mAdapter = new HomeCTextAdapter(R.layout.home_c_item_text, mBeans);
        mRecyclerView.setAdapter(mAdapter);

    }


}
